package com.drojian.demo1.test1;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.drojian.demo.R;

public class ToolButtonActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {

    private TextView result;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tool_button);
        Button back = findViewById(R.id.back);

        CheckBox sw = findViewById(R.id.switch3);
        result = findViewById(R.id.switchStatue2);

        sw.setOnCheckedChangeListener(this);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        String format = String.format("您的开关状态为：%s", isChecked ? "开" : "关");
        result.setText(format);
    }
}